<template>
  <div>
    <el-tabs v-model="tabActivity">
      <el-tab-pane label="供应商报名表" :name="1">
        <div class="pd-table-data statistic-filter" v-if="Object.values(formAnalysis)?.length">
          <statisticFilter v-loading="formAnalysisLoading" :formAnalysisParams="formAnalysisParams" :formAnalysis="formAnalysis" :formId="formId" :isBidding="true" @refreshData="refreshData">
            <template #footer-pagenation>
              <el-pagination class="statistic-filter-pagenation" v-model:current-page="formAnalysisParams.currentPage" v-model:page-size="formAnalysisParams.pageSize" :page-sizes="[10, 30, 50, 100]" :small="true" layout="total, sizes, prev, pager, next, jumper" :total="formAnalysisParams.total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
            </template>
          </statisticFilter>
        </div>
      </el-tab-pane>
    </el-tabs>
    <el-tabs v-model="tabActivity2" style="margin-top: 20px">
      <el-tab-pane :name="1">
        <template #label>
          <span class="custom-tabs-label">
            <span>审核通过供应商列表</span>
            <span style="color: #f00; font-size: 12px; margin-left: 10px">审核通过供应商数量 {{formAnalysis2?.list?.formAnalysisData?.length || 0}} 个</span>
          </span>
        </template>
        <div class="pd-table-data statistic-filter" v-if="Object.values(formAnalysis2)?.length">
          <statisticFilter v-loading="formAnalysisLoading2" :formAnalysisParams="formAnalysisParams2" :formAnalysis="formAnalysis2" :formId="formId" :isBidding="true" @refreshData="refreshData">
            <template #footer-pagenation>
              <el-pagination class="statistic-filter-pagenation" v-model:current-page="formAnalysisParams2.currentPage" v-model:page-size="formAnalysisParams2.pageSize" :page-sizes="[10, 30, 50, 100]" :small="true" layout="total, sizes, prev, pager, next, jumper" :total="formAnalysisParams2.total" @size-change="handleSizeChange2" @current-change="handleCurrentChange2" />
            </template>
          </statisticFilter>
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script setup>
import { ref, toRefs } from 'vue'
import statisticFilter from '@/views/bidding/project/components/statisticFilter.vue'
// import { ElMessage } from 'element-plus'
import { getVendorEnrollList } from '@/api/bidding'
const props = defineProps({
  supplierList: {
    type: Array,
    default: () => [],
  },
  baseForm: {
    type: Object,
    default: () => ({}),
  },
})
const { baseForm } = toRefs(props)

const tabActivity = ref(1)
const tabActivity2 = ref(1)

const formId = baseForm.value.needFormId
const projectId = baseForm.value.id
// 获取统计分析 全部
const formAnalysisParams = ref({
  currentPage: 1,
  pageSize: 10,
  total: 0,
  id: projectId, //项目id
  formId: formId, //表单id
  resource: 0, //来源
  status: -1, //状态 -1全部 0待审核 1已通过 2不通过
})
const formAnalysis = ref({})
const formAnalysisLoading = ref([])
const handlegetVendorEnrollList = async () => {
  formAnalysisLoading.value = true
  let res = await getVendorEnrollList(formAnalysisParams.value)
  formAnalysis.value = res.data
  // 去除二级标题
  try {
    formAnalysis.value.formAnalysisProp = formAnalysis.value.formAnalysisProp.filter((item) => item.prop.indexOf('secondTitle') === -1)
  } catch (error) {
    console.log(error)
  }
  formAnalysisParams.value.total = res.data.total
  formAnalysisLoading.value = false
}
handlegetVendorEnrollList()
const handleSizeChange = (size) => {
  formAnalysisParams.value.pageSize = size
  handlegetVendorEnrollList()
}
const handleCurrentChange = (page) => {
  formAnalysisParams.value.currentPage = page
  handlegetVendorEnrollList()
}
// 获取统计分析 已通过
const formAnalysisParams2 = ref({
  currentPage: 1,
  pageSize: 10,
  total: 0,
  id: projectId, //表单id
  formId: formId, //表单id
  resource: 0, //来源
  status: 1, //状态 -1全部 0待审核 1已通过 2不通过
})
const formAnalysis2 = ref({})
const formAnalysisLoading2 = ref([])
const handlegetVendorEnrollList2 = async () => {
  formAnalysisLoading2.value = true
  let res = await getVendorEnrollList(formAnalysisParams2.value)
  formAnalysis2.value = res.data
  // 去除二级标题
  try {
    formAnalysis2.value.formAnalysisProp = formAnalysis2.value.formAnalysisProp.filter((item) => item.prop.indexOf('secondTitle') === -1)
  } catch (error) {
    console.log(error)
  }
  formAnalysisParams2.value.total = res.data.total
  formAnalysisLoading2.value = false
}
handlegetVendorEnrollList2()

const handleSizeChange2 = (size) => {
  formAnalysisParams2.value.pageSize = size
  handlegetVendorEnrollList2()
}
const handleCurrentChange2 = (page) => {
  formAnalysisParams2.value.currentPage = page
  handlegetVendorEnrollList2()
}
const refreshData = () => {
  handlegetVendorEnrollList()
  handlegetVendorEnrollList2()
}
</script>
<style scoped lang='scss'>
.statistic-filter-pagenation {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 10px;
}
</style>